package com.lantosec.hmrp.modules.monitor.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lantosec.hmrp.core.kit.PageVO;
import com.lantosec.hmrp.core.kit.Result;
import com.lantosec.hmrp.core.mvc.BaseController;
import com.lantosec.hmrp.modules.monitor.entity.WarningDataEntity;
import com.lantosec.hmrp.modules.monitor.entity.WarningTotalEntity;
import com.lantosec.hmrp.modules.monitor.service.IMonitorWarningService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *
 * 预警数据 控制器
 *
 * @author AutoCode
 * @since 2020-05-27
 */
@Api(value = "大屏预警控制器", tags = "大屏预警控制器")
@RestController
@RequestMapping("/monitor/warning")
@Log4j2
public class MonitorWarningController extends BaseController {

    @Autowired
    private IMonitorWarningService warningService;

    @GetMapping("getWarningTotal")
    @ApiOperation(value = "获取预警汇总数字")
    public Result<WarningTotalEntity> getWarningTotal(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year){
        WarningTotalEntity param = warningService.getWarningTotal(month,year);
        return Result.ok(param);
    }

    @GetMapping("getWarningDisposalRate")
    @ApiOperation(value = "根据预警处置率排名")
    public Result<List<WarningTotalEntity>> getWarningDisposalRate(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year){
        List<WarningTotalEntity> param = warningService.getWarningDisposalRate(month,year);
        return Result.ok(param);
    }

    @GetMapping("getChargeDeptRate")
    @ApiOperation(value = "根据预警处置科室处置率排名")
    public Result<List<WarningTotalEntity>> getChargeDeptRate(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year){
        List<WarningTotalEntity> param = warningService.getChargeDeptRate(month,year);
        return Result.ok(param);
    }

    @GetMapping("getWarningDetailsList")
    @ApiOperation(value = "预警详细列表")
    public Result<List<WarningTotalEntity>> getWarningDetailsList(
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "类型，1全部，2已出置，3未处置，4违规") @RequestParam(name = "type",required = false) Integer type,
            @ApiParam(value = "部门id") @RequestParam(name = "deptId",required = false) String deptId){
        List<WarningTotalEntity> param = warningService.getWarningDetailsList(month,year,type,deptId);
        return Result.ok(param);
    }

    @GetMapping("getWarningData")
    @ApiOperation(value = "根据规则以及状态查看预警数据")
    public Result<Page<WarningDataEntity>> getWarningData(
            @ApiParam(value = "分页对象", required = true) PageVO<WarningDataEntity> page,
            @ApiParam(value = "月份") @RequestParam(name = "month",required = false) String month,
            @ApiParam(value = "年份") @RequestParam(name = "year",required = false) String year,
            @ApiParam(value = "类型，1全部，2已出置，3未处置，4违规，5正常") @RequestParam(name = "type") Integer type,
            @ApiParam(value = "预警规则id") @RequestParam(name = "ruleId",required = false) String ruleId,
            @ApiParam(value = "处置部门id") @RequestParam(name = "deptId",required = false) String deptId){
        Page<WarningDataEntity> param = warningService.getWarningData(page,month,year,type,ruleId,deptId);
        return Result.ok(param);
    }

    @GetMapping("getWarningHaveDone")
    @ApiOperation(value = "预警工作台已办")
    public Result<Page<WarningDataEntity>> getWarningHaveDone(
            @ApiParam(value = "分页对象", required = true) PageVO<WarningDataEntity> page){
        String userId = getUserId();
        Page<WarningDataEntity> param = warningService.getWarningWorkbench(page,userId);
        return Result.ok(param);
    }

    @GetMapping("getWarningHaveDoneDetails")
    @ApiOperation(value = "预警工作台已办详情")
    public Result<Page<WarningDataEntity>> getWarningHaveDoneDetails(
            @ApiParam(value = "分页对象", required = true) PageVO<WarningDataEntity> page,
            @ApiParam(value = "预警规则id") @RequestParam(name = "ruleId") String ruleId){
        String userId = getUserId();
        Page<WarningDataEntity> param = warningService.getWarningHaveDoneDetails(page,userId,ruleId);
        return Result.ok(param);
    }

    @GetMapping("getWarningBacklog")
    @ApiOperation(value = "预警工作台待办")
    public Result<List<WarningDataEntity>> getWarningBacklog(){
        String userId = getUserId();
        List<WarningDataEntity> param = warningService.getWarningBacklog(userId);
        return Result.ok(param);
    }

    @GetMapping("getWarningBacklogDetails")
    @ApiOperation(value = "预警工作台待办详情")
    public Result<Page<WarningDataEntity>> getWarningBacklogDetails(
            @ApiParam(value = "分页对象", required = true) PageVO<WarningDataEntity> page,
            @ApiParam(value = "预警规则id") @RequestParam(name = "ruleId") String ruleId){
        Page<WarningDataEntity> param = warningService.getWarningBacklogDetails(page,ruleId);
        return Result.ok(param);
    }
}
